package model.service;

import java.util.List;

import model.dao.IQuestionarioDAO;
import model.entity.Questionario;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 *
 * Questionario Service
 *
 * @author Alex
 *
 */
@Service(value = "questionarioService")
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public class QuestionarioService implements IQuestionarioService {

	// QuestionarioDAO is injected...
	@Autowired
	IQuestionarioDAO questionarioDAO;

	/**
	 * Add Questionario
	 *
	 * @param Questionario
	 *            questionario
	 */
	@Transactional(readOnly = false)
	@Override
	public void addQuestionario(Questionario questionario) {
		getQuestionarioDAO().addQuestionario(questionario);
	}

	/**
	 * Delete Questionario
	 *
	 * @param Questionario
	 *            questionario
	 */
	@Transactional(readOnly = false)
	@Override
	public void deleteQuestionario(Questionario questionario) {
		getQuestionarioDAO().deleteQuestionario(questionario);
	}

	/**
	 * Update Questionario
	 *
	 * @param Questionario
	 *            questionario
	 */
	@Transactional(readOnly = false)
	@Override
	public void updateQuestionario(Questionario questionario) {
		getQuestionarioDAO().updateQuestionario(questionario);
	}

	/**
	 * Get Questionario
	 *
	 * @param int Questionario Id
	 */
	@Override
	public Questionario getQuestionarioById(int id) {
		return getQuestionarioDAO().getQuestionarioById(id);
	}

	/**
	 * Get Questionario List
	 *
	 */
	@Override
	public List<Questionario> getQuestionarios() {
		return getQuestionarioDAO().getQuestionarios();
	}

	/**
	 * Get Questionario DAO
	 *
	 * @return IQuestionarioDAO - Questionario DAO
	 */
	public IQuestionarioDAO getQuestionarioDAO() {
		return questionarioDAO;
	}

	/**
	 * Set Questionario DAO
	 *
	 * @param IQuestionarioDAO
	 *            - Questionario DAO
	 */
	public void setQuestionarioDAO(IQuestionarioDAO questionarioDAO) {
		this.questionarioDAO = questionarioDAO;
	}
}
